package com.shopnight.config;


import com.shopnight.interceptors.JWTInterceptor;
import com.shopnight.interceptors.ScriptInterceptors;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration //定义此类为配置类，及相当于之前的xml文件
public class InterceptorConfig implements WebMvcConfigurer{

		@Override
		public void addInterceptors(InterceptorRegistry registry) {


// 注册token令牌拦截器
//				String[] excludePathPatterns = {"/api/userLogin"};
				//已经提供了拦截器注册类 放进来相当于定义了一个bean
           registry.addInterceptor(new JWTInterceptor())
									 .addPathPatterns("/api/token/**");
//									 .excludePathPatterns(excludePathPatterns);


//注册脚本拦截器
//			String[] InterceptPath = {"/api/token/addIndent","/api/token/addToCart","/api/token/addOrUpdateAddress"};
//			registry.addInterceptor(new ScriptInterceptors())
//					.addPathPatterns(InterceptPath);


		}

}
